package cn.tedu.spring.dibase;

import cn.tedu.spring.example.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    @Value("查看购物车")
    private String name;
    /*
        1.Autowired注解:白动装配,注入对象或接口类型的数据;
        2.添加位置:
            2.1 属性上
            2.2 setter方法上
            2.3 构造方法上

     */
//    @Autowired
    private UserDao userDao;
//    @Autowired
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }
    @Autowired
    public UserService(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public String toString() {
        return "UserService{" +
                "name='" + name + '\'' +
                ", userDao=" + userDao +
                '}';
    }
}
